//
//  DYForgetVerViewController.m
//  DYHospital
//
//  Created by 胡金东 on 16/3/23.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "DYForgetRegistViewController.h"
#import "UIView+Color.h"
#import "UIViewController+DYLoadView.h"

@interface DYForgetRegistViewController ()
@property (nonatomic,strong)UITextField *passwordField;
@property (nonatomic,strong)UITextField *againPasswField;
@property (nonatomic,strong)UIButton *forgetResBtn;

@end

@implementation DYForgetRegistViewController

-(void)viewWillAppear:(BOOL)animated
{
    UIBarButtonItem *backBtnItem =[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"back_Arrow"] style:UIBarButtonItemStylePlain target:self action:@selector(backBtnItemClick)];
    //,tintColor的特性,我们可以对镂空的图片(如tabbar的image和 BarButtonItem的image)进行设置tintColor就可以设置改变镂空图片的颜色
    backBtnItem.tintColor = [UIColor blackColor];
    self.navigationItem.leftBarButtonItem = backBtnItem;
}
-(void)backBtnItemClick
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setField];
    self.view.backgroundColor = [UIColor lightGrayColor];
}

-(void)setField
{
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat w = 0;
    CGFloat h = 0;
    
    x = 20;
    y = 64 + 25;
    w = [UIScreen mainScreen].bounds.size.width - 40;
    h = 35;
    self.passwordField = [[UITextField alloc]initWithFrame:CGRectMake(x, y, w, h)];
    self.passwordField.placeholder = @"请输入密码";
    self.passwordField.backgroundColor = [UIColor whiteColor];
    self.passwordField.keyboardType = UIKeyboardTypeDecimalPad;
    self.passwordField.clearButtonMode = UITextFieldViewModeUnlessEditing;
    [self.passwordField setRadius:5 borderWith:0 borderColor:[UIColor clearColor]];
    [self.view addSubview:self.passwordField];
    
    x = x;
    y = y + h + 10;
    w = w;
    h = h;
    self.againPasswField = [[UITextField alloc]initWithFrame:CGRectMake(x, y, w, h)];
    self.againPasswField.placeholder = @"请再次输入密码";
    self.againPasswField.backgroundColor = [UIColor whiteColor];
    self.againPasswField.keyboardType = UIKeyboardTypeDecimalPad;
    self.againPasswField.clearButtonMode = UITextFieldViewModeUnlessEditing;
    [self.againPasswField setRadius:5 borderWith:0 borderColor:[UIColor clearColor]];
    [self.view addSubview:self.againPasswField];
    
    x = x;
    y = y + h + 50;
    w = w;
    h = h;
    self.forgetResBtn = [[UIButton alloc]initWithFrame:CGRectMake(x, y, w, h)];
    [self.forgetResBtn setTitle:@"完成" forState:UIControlStateNormal];
    self.forgetResBtn.backgroundColor = [UIColor purpleColor];
    [self.forgetResBtn addTarget:self action:@selector(forgetResBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.forgetResBtn setRadius:5 borderWith:0 borderColor:[UIColor clearColor]];
    [self.view addSubview:self.forgetResBtn];
    

    
}


-(void)forgetResBtnClick
{
    if ([self.passwordField.text isEqualToString:self.againPasswField.text]) {
        
        [self showHint:@"重置密码成功" inCenter:YES];
    }else{
        [self showHint:@"两次输入密码不一致" inCenter:YES];
    }
}


@end
